
#include "client.h"
#include "log.h"
#include "gui/widgets.h"
#include "gui/clientproxy.h"
#include <thread>
#include <memory>

const char* PIPENAME = "\\\\.\\pipe\\hym.sock";

//------------------------------------------------------------------------------


void on_ui(Client* arg)
{
#if !SDL_VERSION_ATLEAST(2,0,17)
#error This backend requires SDL 2.0.17+ because of SDL_RenderGeometry() function
#endif
	std::shared_ptr<Client> clt(arg);
	auto sp = std::static_pointer_cast<Session>(clt);
	ClientProxy::getInstance().setClient(sp);

	MainWindow w;
	Console c;
	w.run();
	clt->~Client();
}

int main(int argc, char**argv){

	Client c(1);

	//起UI线程
	std::thread gui_t(on_ui, &c);

	Dispatcher::Loop();
	gui_t.join();


	return 0;
}
